package com.concurrency.practise.controller;

import com.concurrency.practise.entity.Dog;
import com.concurrency.practise.service.DogQueryService;
import com.concurrency.practise.service.SynchronizeService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @program: currency_practise
 * @description:
 * @author: Jiliang.Lee
 * @create: 2019-12-12 10:55
 **/
@RestController
@RequestMapping("/dogs")
@AllArgsConstructor
public class DogController {
	private final SynchronizeService synchronizeService;
	private final DogQueryService dogQueryService;

	@PutMapping
	public Dog buyDog() throws Exception {
		return synchronizeService.synchronizedBuyDog();
	}
	@PutMapping("/db")
	public Dog buyDogWithDb() {
		return synchronizeService.synchronizedBuyDogWithDb();
	}

	@GetMapping
	public Dog getDog(@RequestParam("id") Long id) {
		return dogQueryService.getDog(id);
	}
}
